import {message} from 'antd';
import {formatMessage} from '../intl';
export const newOrUpdateOrderValidator = (data, dealerId) => {
    const requiredFields = [];
    if(!data.serviceName)
        requiredFields.push(formatMessage({
            id: 'validator.message.serviceName',
            defaultMessage: '技术升级主题'
        }));
    if(!data.brandId)
        requiredFields.push(formatMessage({
            id: 'validator.message.brandId',
            defaultMessage: '品牌'
        }));
    if(!dealerId)
        requiredFields.push(formatMessage({
            id: 'validator.message.dealerId',
            defaultMessage: '总代'
        }));
    if(!data.content)
        requiredFields.push(formatMessage({
            id: 'validator.message.content',
            defaultMessage: '主要内容'
        }));
    if(!data.vehicleCategory)
        requiredFields.push(formatMessage({
            id: 'validator.message.vehicleCategory',
            defaultMessage: '车辆类别'
        }));
    if(data.isClaimPart === undefined)
        requiredFields.push(formatMessage({
            id: 'validator.message.isClaimPart',
            defaultMessage: '是否索赔备件'
        }));
    if(data.isClaimAssist === undefined)
        requiredFields.push(formatMessage({
            id: 'validator.message.isClaimAssist',
            defaultMessage: '是否索赔辅料'
        }));
    if(data.technologyActivityDate.length === 0)
        requiredFields.push(formatMessage({
            id: 'validator.message.technologyActivityDate',
            defaultMessage: '技术升级截止日期'
        }));
    if(!data.supplierCode)
        requiredFields.push(formatMessage({
            id: 'validator.message.supplierCode',
            defaultMessage: '供应商编号'
        }));
    if(!data.dutyUnitCode)
        requiredFields.push(formatMessage({
            id: 'validator.message.dutyUnitCode',
            defaultMessage: '主要责任部门'
        }));
    if(requiredFields.length > 0) {
        message.warning(`${requiredFields.join('，')}${formatMessage({
            id: 'validator.message.required',
            defaultMessage: '必填!'
        })}`);
        return false;
    }
    if(!(data.checkLabor || data.checkChangeLabor || data.checkChangeAssistLabor)) {
        message.warning(`${formatMessage({
            id: 'validator.message.checkLabor',
            defaultMessage: '工时必填一个'
        })}`);
        return false;
    }
    if(!data.id)
        if(!(data.productCategoryId || (data.beginVIN && data.endVIN) || data.rolloutDate)) {
            message.warning(`${formatMessage({
                id: 'validator.message.wholesaleDealerId',
                defaultMessage: '车辆查询条件必填一个'
            })}`);
            return false;
        }
    if(!data.attachments || (data.attachments && data.attachments.length === 0)) {
        message.warning(`${formatMessage({
            id: 'validator.message.attachments',
            defaultMessage: '附件不能为空'
        })}`);
        return false;
    }
    return true;
};
